package com.qf.quduba.service.impl;

import com.qf.quduba.dao.BookDAO;
import com.qf.quduba.dao.BookInfoDao;
import com.qf.quduba.dao.TypeDAO;
import com.qf.quduba.entity.Books;
import com.qf.quduba.entity.Type;
import com.qf.quduba.service.BookService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 17312
 * @time2020/10/1114:42
 */
@Service
public class BookServiceImpl implements BookService {
    @Resource
    private BookDAO bookDAO;

    @Resource
    private TypeDAO typeDAO;

    @Resource
    private BookInfoDao bookInfoDao;


    @Override
    public int updateHits(Integer bookId) {
        return bookDAO.updateHits(bookId);
    }

    @Override
    public List<Books> getHotBook() {
        return bookDAO.getHotBook();
    }

    @Override
    public List<Books> getCollect() {
        return bookDAO.getCollect();
    }

    @Override
    public List<Books> getUpdate() {
        return bookDAO.getUpdate();
    }

    @Override
    public List<Books> getCreattime() {
        return bookDAO.getCreattime();
    }

    @Override
    public List<Books> getRenewal() {
        return bookDAO.getRenewal();
    }

    @Override
    public List<Type> getTypeList() {
        return typeDAO.getTypeList();
    }

    @Override
    public List<Books> getAllBooks() {
        return bookDAO.getAllBooks();
    }

    @Override
    public List<Books> findHitsEnd() {
        return bookDAO.findHitsEnd();
    }

    @Override
    public int updateCollect(String bookId) {
        return bookDAO.updateCollect(bookId);
    }

    @Override
    public List<Books> getBooksData(Integer userId) {
        return bookDAO.getBooksData(userId);
    }

    @Override
    public int getAggregate(Integer userId) {
        return bookDAO.getAggregate(userId);
    }

    @Override
    public int updateReward(String bookId,double money) {
        Books book = bookInfoDao.findBookInfo(bookId);
        double newBookReward=book.getBookReward()+money;
        return bookDAO.updateReward(bookId,newBookReward);
    }

    @Override
    public int addBook(Books books) {
        return bookDAO.addBook(books);
    }

    @Override
    public int updateBook(Books books) {
        return bookDAO.updateBook(books);
    }
}
